package cc.Controller;/*
package cc.Controller;

import cc.Entity.AdminInfo;
import cc.Service.AdminService;
import cc.Utils.ListToResultUtil;
import cc.Utils.MD5Util;
import cc.Entity.Results;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.cc.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

*/

import cc.Entity.AdminInfo;
import cc.Entity.Results;
import cc.ServiceImpl.AdminServiceImpl;
import cc.Utils.ListToResultUtil;
import cc.Utils.MD5Util;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @Auther: ${张智杰}
 * @Date: 2018/10/7 09:43
 * @Description:
 */

@Controller
public class AdminController {
  /*  @Autowired
    private AdminService adminService;*/
    @Autowired
    private AdminServiceImpl adminService;


    @ResponseBody
    @RequestMapping(value = "/login",method = RequestMethod.POST)
    public Results Login(@RequestBody AdminInfo admin){

    admin.setAdminPassword(MD5Util.getMD5(admin.getAdminPassword()));

    if(admin.getAdminAccount().equals(null) || admin.getAdminAccount().equals("")
            || admin.getAdminPassword().equals(null) || admin.getAdminPassword().equals("")){
        return ListToResultUtil.getResult(false,"01","输入不能为空",null);
    }else{
        AdminInfo admin1 = adminService.getpassword(admin.getAdminAccount());
        if(null == admin1){
            return ListToResultUtil.getResult(false
                    ,"02","账号不存在",null);
        }else{
            if(admin1.getAdminPassword().equals(admin.getAdminPassword())){
                return ListToResultUtil.getResult(true
                        ,"00","登录成功",null);
            }else {
                return ListToResultUtil.getResult(false
                        ,"03","密码错误",null);
            }
        }
    }
    }

}

